﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using CreditAgricole.Framework;

namespace CreditAgricole.PageCodeBehind
{
    public partial class Menu : UserControl
    {

        #region Properties

        /// <summary>
        /// pnlMenu control.
        /// </summary>
        protected Panel pnlMenu;

        /// <summary>
        /// myCreatedTasks control.
        /// </summary>
        protected ElementMenu myCreatedTasks;

        /// <summary>
        /// pnlCritiriaElem1 control.
        /// </summary>
        protected Panel pnlCritiriaElem1;

        /// <summary>
        /// elem1cirtiria1 control.
        /// </summary>
        protected ElementMenu elem1cirtiria1;

        /// <summary>
        /// elem1cirtiria2 control.
        /// </summary>
        protected ElementMenu elem1cirtiria2;

        /// <summary>
        /// tasksToBeValidated control.
        /// </summary>
        protected ElementMenu tasksToBeValidated;

        /// <summary>
        /// pnlCritiriaElem2 control.
        /// </summary>
        protected Panel pnlCritiriaElem2;

        /// <summary>
        /// elem2cirtiria1 control.
        /// </summary>
        protected ElementMenu elem2cirtiria1;

        /// <summary>
        /// elem2cirtiria2 control.
        /// </summary>
        protected ElementMenu elem2cirtiria2;

        /// <summary>
        /// validatedTasks control.
        /// </summary>
        protected ElementMenu validatedTasks;

        /// <summary>
        /// pnlCritiriaElem3 control.
        /// </summary>
        protected Panel pnlCritiriaElem3;

        /// <summary>
        /// elem3cirtiria1 control.
        /// </summary>
        protected ElementMenu elem3cirtiria1;

        /// <summary>
        /// elem3cirtiria2 control.
        /// </summary>
        protected ElementMenu elem3cirtiria2;

        /// <summary>
        /// allTasks control.
        /// </summary>
        protected ElementMenu allTasks;

        /// <summary>
        /// pnlCritiriaElem4 control.
        /// </summary>
        protected Panel pnlCritiriaElem4;

        /// <summary>
        /// elem4cirtiria1 control.
        /// </summary>
        protected ElementMenu elem4cirtiria1;

        /// <summary>
        /// elem4cirtiria2 control.
        /// </summary>
        protected ElementMenu elem4cirtiria2;

        /// <summary>
        /// allCreatedTasks control.
        /// </summary>
        protected ElementMenu allCreatedTasks;

        /// <summary>
        /// pnlCritiriaElem5 control.
        /// </summary>
        protected Panel pnlCritiriaElem5;

        /// <summary>
        /// elem5cirtiria1 control.
        /// </summary>
        protected ElementMenu elem5cirtiria1;

        /// <summary>
        /// elem5cirtiria2 control.
        /// </summary>
        protected ElementMenu elem5cirtiria2;

        /// <summary>
        /// private access to selectedMenu item
        /// </summary>
        private Constants.ElementsMenu selectedMenu;

        /// <summary>
        /// Selected menu publicly accessed
        /// </summary>
        public Constants.ElementsMenu SelectedMenu
        {
            get { return selectedMenu; }
            set { selectedMenu = value; }
        }

        /// <summary>
        /// private access to selectedCritiria item
        /// </summary>
        private Constants.ElementsMenuCritiria selectedCritiria;

        /// <summary>
        /// Selected critiria publicly accessed
        /// </summary>
        public Constants.ElementsMenuCritiria SelectedCritiria
        {
            get { return selectedCritiria; }
            set { selectedCritiria = value; }
        }

        #endregion

        /// <summary>
        /// Call when the control is loaded in the page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            SelectItem(SelectedMenu, SelectedCritiria);
        }

        /// <summary>
        /// The Selected menu call select menu to apply CSS
        /// </summary>
        /// <param name="selectedMenu">Selected menu</param>
        /// <param name="selectedCritiria">Selected critiria</param>
        public void SelectItem(Constants.ElementsMenu selectedMenu, Constants.ElementsMenuCritiria selectedCritiria)
        {
            switch (selectedMenu)
            {
                case Constants.ElementsMenu.TasksToBeValidatedTag:
                    {
                        pnlCritiriaElem1.Visible = true;
                        tasksToBeValidated.Selected();
                        #region Select Critiria
                        switch (selectedCritiria)
                        {
                            case Constants.ElementsMenuCritiria.FirstCritiria:
                                elem1cirtiria1.Selected();
                                break;
                            case Constants.ElementsMenuCritiria.SecondCritiria:
                                elem1cirtiria2.Selected();
                                break;
                            default:
                                elem1cirtiria1.Selected();
                                break;
                        }
                        #endregion
                        break;
                    }
                case Constants.ElementsMenu.MyCreatedTasksTag:
                    {
                        pnlCritiriaElem2.Visible = true;
                        myCreatedTasks.Selected();
                        #region Select Critiria
                        switch (selectedCritiria)
                        {
                            case Constants.ElementsMenuCritiria.FirstCritiria:
                                elem2cirtiria1.Selected();
                                break;
                            case Constants.ElementsMenuCritiria.SecondCritiria:
                                elem2cirtiria2.Selected();
                                break;
                            default:
                                elem2cirtiria1.Selected();
                                break;
                        }
                        #endregion
                        break;
                    }
                case Constants.ElementsMenu.ValidatedTasksTag:
                    {
                        pnlCritiriaElem3.Visible = true;
                        validatedTasks.Selected();
                        #region Select Critiria
                        switch (selectedCritiria)
                        {
                            case Constants.ElementsMenuCritiria.FirstCritiria:
                                elem3cirtiria1.Selected();
                                break;
                            case Constants.ElementsMenuCritiria.SecondCritiria:
                                elem3cirtiria2.Selected();
                                break;
                            default:
                                elem3cirtiria1.Selected();
                                break;
                        }
                        #endregion
                        break;
                    }
                case Constants.ElementsMenu.AllTasksTag:
                    {
                        pnlCritiriaElem4.Visible = true;
                        allTasks.Selected();
                        #region Select Critiria
                        switch (selectedCritiria)
                        {
                            case Constants.ElementsMenuCritiria.FirstCritiria:
                                elem4cirtiria1.Selected();
                                break;
                            case Constants.ElementsMenuCritiria.SecondCritiria:
                                elem4cirtiria2.Selected();
                                break;
                            default:
                                elem4cirtiria1.Selected();
                                break;
                        }
                        #endregion
                        break;
                    }
                case Constants.ElementsMenu.AllCreatedTasksTag:
                    {
                        pnlCritiriaElem5.Visible = true;
                        allCreatedTasks.Selected();
                        #region Select Critiria
                        switch (selectedCritiria)
                        {
                            case Constants.ElementsMenuCritiria.FirstCritiria:
                                elem5cirtiria1.Selected();
                                break;
                            case Constants.ElementsMenuCritiria.SecondCritiria:
                                elem5cirtiria2.Selected();
                                break;
                            default:
                                elem5cirtiria1.Selected();
                                break;
                        }
                        #endregion
                        break;
                    }
            }
        }
    }
}
